<?php

$currentPage = $_SERVER["PHP_SELF"];

$colname_past4 = "-1";
if (isset($_GET['sa'])) {
  $colname_past4 = $_GET['sa'];
}
mysql_select_db($database_konek, $konek);
$query_past4 = sprintf("SELECT * FROM template WHERE id = %s", GetSQLValueString($colname_past4, "int"));
$past4 = mysql_query($query_past4, $konek) or die(mysql_error());
$row_past4 = mysql_fetch_assoc($past4);
$totalRows_past4 = mysql_num_rows($past4);
if ($totalRows_past4>0) {
$maxRows_past3 = $row_past4['perpage'];
$sc = 0;
if (isset($_GET['sc'])) {
  $sc = $_GET['sc'];
}
$startRow_past3 = $sc * $maxRows_past3;

$colname_past3 = "-1";
if (isset($row_past4['id'])) {
  $colname_past3 = $row_past4['id'];
}
mysql_select_db($database_konek, $konek);
$query_past3 = sprintf("SELECT * FROM template_data WHERE id_module = %s", GetSQLValueString($colname_past3, "int"));
$query_limit_past3 = sprintf("%s LIMIT %d, %d", $query_past3, $startRow_past3, $maxRows_past3);
$past3 = mysql_query($query_limit_past3, $konek) or die(mysql_error());
$row_past3 = mysql_fetch_assoc($past3);

if (isset($_GET['totalRows_past3'])) {
  $totalRows_past3 = $_GET['totalRows_past3'];
} else {
  $all_past3 = mysql_query($query_past3);
  $totalRows_past3 = mysql_num_rows($all_past3);
}
$totalPages_past3 = ceil($totalRows_past3/$maxRows_past3)-1;

$queryString_past3 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "sc") == false && 
        stristr($param, "totalRows_past2") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_past3 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_past3 = sprintf("&totalRows_past2=%d%s", $totalRows_past3, $queryString_past3);
?>


    
	  <div class="<?php echo $classjudul ?>">
<?php echo $row_past4['judul']; ?>
</div>
<div  class="<?php echo $classcontent; ?>">
<div class="row">
  <?php $num=0; do { ?>
  
  <div class="col-sm-6 col-md-3 col-lg-3">
    <div class="thumbnail">
      <img src="<?php echo $base_url ?>/g-konten/fm/template/<?php echo $row_past4['id']; ?>/thumb/<?php echo $row_past3['image']; ?>" alt="<?php echo $num++ ?>" alt="<?php echo $row_past3['nama']; ?>">
      <div class="caption">
        <h3><?php echo $row_past3['nama']; ?></h3>
        <p><a href="#" class="btn btn-primary" role="button"> <i class="fa fa-external-link"></i> Live Demo</a> <a href="#" class="btn btn-default" role="button"><i class="fa fa-download"></i> Buy Now</a></p>
      </div>
    </div>
  </div>
  
    <?php } while ($row_past3 = mysql_fetch_assoc($past3)); ?>
</div>
<div style="width:100%; margin-top:20px">
<div class="btn-group">
  <?php if ($sc > 0) { // Show if not first page ?>
        <a href="<?php echo $base_url ?>/p/<?php echo $_GET['p'] ?>/<?php echo $_GET['link'] ?>/<?php echo $_GET['sa'] ?>/<?php echo $_GET['sb'] ?>/<?php echo $sc-1 ?>">
  <button type="button" class="btn btn-default">Previous</button>
  </a><?php } // Show if not first page ?>
<?php if ($sc < $totalPages_past3) { // Show if not last page ?>
        <a href="<?php echo $base_url ?>/p/<?php echo $_GET['p'] ?>/<?php echo $_GET['link'] ?>/<?php echo $_GET['sa'] ?>/<?php echo $_GET['sb'] ?>/<?php echo $sc+1 ?>"><button type="button" class="btn btn-default">Next</button></a>
        <?php } // Show if not last page ?>
</div>
</div>
</div>
<?php
mysql_free_result($past3);
}
mysql_free_result($past4);
?>
